package edu.uclmgmu.bacteriosec.aspects.com.mysql.jdbc.ResultSet.getInt;

//import com.mysql.jdbc.ResultSet;
import edu.uclmgmu.bacteriosec.aspects.common.FilesStore;
import com.mysql.jdbc.*;

privileged aspect Decrease {

	int around(java.sql.ResultSet caller, int col) : target(caller) && args(col) && 
			call(* java.sql.ResultSet.getInt(int)) && !call(* com.mysql.jdbc.ResultSet.getInt(int)) &&
			!cflow(within(Decrease)) && !within(edu.uclmgmu.bacteriosec.aspects.common.FilesStore) {
		String metodoQueToca = FilesStore.loadMethodInTurn();
		String signature=thisJoinPointStaticPart.getSignature().toString();
		if (metodoQueToca.equals(signature)) {
			int numberOfCallInTurn = FilesStore.loadCallInTurn();
			int numberOfCurrentCall = FilesStore.loadCurrentCall();
			String testCase=FilesStore.loadCurrentTestCase();
			if (numberOfCallInTurn == numberOfCurrentCall) {
				FilesStore.createFileForCurrentCall(metodoQueToca, testCase, numberOfCurrentCall+1);
				col=col-1;
				return proceed(caller, col);
			} else {
				FilesStore.createFileForCurrentCall(metodoQueToca, testCase, numberOfCurrentCall+1);
				return proceed(caller, col);
			}
		} else {
			return proceed(caller, col);
		}
	}

}
